from django import forms

from . import models


class SelectClassForm(forms.Form):
    class_name = models.Class.objects.values_list('class_name')
    class_list = []
    for i in class_name:
        for j in i:
            class_list.append(j)
    SELVALUE = []
    for i in range(len(class_list)):
        SELVALUE.append((i + 1, class_list[i]))
    SELVALUE = tuple(SELVALUE)

    classId = forms.IntegerField(widget=forms.widgets.Select(choices=SELVALUE))


class SelectUsertypeForm(forms.Form):
    SELVALUE = (
        (2, '学生'),
        (1, '老师'),
        (3, '院级管理员'),
        (4, '校级管理员'),
    )
    classId = forms.IntegerField(widget=forms.widgets.Select(choices=SELVALUE))


# class SelectCollegeForm(forms.Form):
#     SELVALUE = (
#         (1, '计算机与通信工程学院'),
#         (2, '土木与资源工程学院'),
#         (3, '冶金与生态工程学院'),
#     )
#     classId = forms.IntegerField(widget=forms.widgets.Select(choices=SELVALUE))

class SelectCollegeForm(forms.Form):
    college_name = models.College.objects.values_list('college_name')
    college_list = []
    for i in college_name:
        for j in i:
            college_list.append(j)
    SELVALUE = []
    for i in range(len(college_list)):
        SELVALUE.append((i + 1, college_list[i]))
    SELVALUE = tuple(SELVALUE)

    classId = forms.IntegerField(widget=forms.widgets.Select(choices=SELVALUE))


class UploadFileForm(forms.Form):
    title = forms.CharField(max_length=50)
    file = forms.FileField()
